#pragma once

#include "components.h"
#include "event.h"
#include "models.h"

#include "qbe/src/ecs/ecs.hpp"

#include "qlib/all.h"
#include "../../state/state.hpp"
#include "../../message/message.hpp"

namespace qbe::BreakUp {
void exit(ecs::Query query, state::AllModeType enter_mode);
void init(entt::registry& reg, ecs::Commands commands, ecs::Query query);
void update(entt::registry& reg, ecs::Query query, ecs::Bus& bus, ecs::EventWriter<msg::RenderEvent> event);
void post(entt::registry& reg, ecs::Commands commands, ecs::Query query, ecs::Bus& bus);

std::vector<entt::entity> getAllGraph(ecs::Query query, qlib::Cell::s_ptr current_cell, std::shared_ptr<qlib::Reference> _ref, bool is_reserve_pcell,
                                      bool is_break_up_all);
class BreakUpPlugin : public ecs::Plugin {
 public:
  void build(ecs::App& app) override {
    app.init_resource<BreakUpModel>(BreakUpModel{});

    app.add_systems<ecs::stage::Startup>(init);
    app.add_systems<ecs::stage::Update>(update);
    app.add_systems<ecs::stage::PostUpdate>(post);
  };
};
}  // namespace qbe::LineAddCorner